#pragma once
#include "Interface.h"

//===========================================================================
// Board
//===========================================================================
class Board : public IBoard
{
public :
     
    Board(
        unsigned int size,
        EPieceType   user,
        EPieceType   computer
    );
    
    ~Board( void );

    const EPieceType * GetPiece(
        const IPosition & position
    ) const;

    bool IsGameOver( void ) const;
    
    void Show( void ) const;

    bool Set(
        const IPosition & position,
              EPieceType  piece
    );
    
    bool Take(
        const IPosition & position
    );

    bool IsValidPosition(
        const IPosition & position
    ) const;

    unsigned int GetSize( void ) const {
        return this->m_size;
    }    
    
    void Release( void );

private :

    void Initialize( void );
    
    void CleanUp( void );
    
    void SetPieces( void );
    
    void IncreasePieceCount(
        EPieceType piece
    );
    
    void DecreasePieceCount(
        EPieceType piece
    );

    static void Release(
        Board * board
    );

    EPieceType ** m_board;
    unsigned int  m_size;

    EPieceType   m_user;
    EPieceType   m_computer;

    unsigned int m_blacks;
    unsigned int m_whites;
};